{% extends "common/default.html" %}
{% block common %}
    <script type="text/javascript">
        function checkForm() {
            var courseName = $("#courseName").val();
            var credit = $("#credit").val();
            var teacherId = $("#teacherId").val();
            if (courseName == null || courseName == "") {
                $("#error").html("课程名称不能为空！");
                return false;
            }
            if (credit == null || credit == "") {
                $("#error").html("学分不能为空！");
                return false;
            }
            if (teacherId == null || teacherId == "") {
                $("#error").html("请选择授课老师！");
                return false;
            }
            return true;
        }

        function resetValue() {
            $("#courseName").val("");
            $("#credit").val("");
            $("#teacherId").val("");
        }
    </script>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">{{ dataType }}</h3>
        </div>
        <div class="panel-body">
            <form class="form-horizontal" role="form" method="post" action="../course_update/"
                  onsubmit="checkForm()">
                {% if error %}
                    <label style="background-color: red">{{ error }}</label>
                {% endif %}
                {% if success %}
                    <label style="background-color: green">{{ success }}</label>
                    <a href="../manager/course_list">点击去查看</a>
                {% endif %}

                <div class="form-group">
                    <label class="col-md-2 control-label">课程名称：</label>
                    <div class="col-md-10">
                        <input type="text" class="form-control" id="courseName" name="courseName" style="width: 300px;" value="{{ course.courseName }}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">学分：</label>
                    <div class="col-md-10">
                        <input type="text" class="form-control" id="credit" name="credit" style="width: 300px;" value="{{ course.credit }}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">授课老师：</label>
                    <div class="col-md-10">
                        <input type="text" class="form-control" id="teacherId" name="teacherId" style="width: 300px;" value="{{ course.teacherId.id }}"
                               placeholder="请输入教师ID">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">开始周：</label>
                    <div class="col-md-10">
                        <select id="startTime" name="startTime">
                            <option value="">请选择</option>
                            {% for time in times %}
                                <option value="{{ time }}">第{{ time }}周</option>
                            {% endfor %}

                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">结束周：</label>
                    <div class="col-md-10">
                        <select id="endTime" name="endTime">
                            <option value="">请选择</option>
                            {% for time in times %}
                                <option value="{{ time }}">第{{ time }}周</option>
                            {% endfor %}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">上课时间</label>
                    <div class="col-md-10">
                        <table border=6 frame=void align=center width=650px height=100px cellspacing=0px
                               cellpadding=10px>
                            <tr height=50px align=center>
                                <th width=110px></th>
                                <th><font color=blue>星期一</font></th>
                                <th><font color=blue>星期二</font></th>
                                <th><font color=blue>星期三</font></th>
                                <th><font color=blue>星期四</font></th>
                                <th><font color=blue>星期五</font></th>
                            </tr>
                            <tr height=40px align=center>
                                <td><font color=blue><b>一</b></font></td>
                                <td><input type="checkbox" id="11" name="11"/></td>
                                <td><input type="checkbox" id="12" name="12"/></td>
                                <td><input type="checkbox" id="13" name="13"/></td>
                                <td><input type="checkbox" id="14" name="14"/></td>
                                <td><input type="checkbox" id="15" name="15"/></td>
                            </tr>
                            <tr height=40px align=center>
                                <td><font color=blue><b>二</b></font>
                                <td><input type="checkbox" id="21" name="21"/></td>
                                <td><input type="checkbox" id="22" name="22"/></td>
                                <td><input type="checkbox" id="23" name="23"/></td>
                                <td><input type="checkbox" id="24" name="24"/></td>
                                <td><input type="checkbox" id="25" name="25"/></td>
                            </tr>
                            <tr height=40px align=center>
                                <td><font color=blue><b>三</b></font>
                                <td><input type="checkbox" id="31" name="31"/></td>
                                <td><input type="checkbox" id="32" name="32"/></td>
                                <td><input type="checkbox" id="33" name="33"/></td>
                                <td><input type="checkbox" id="34" name="34"/></td>
                                <td><input type="checkbox" id="35" name="35"/></td>
                            </tr>
                            <tr height=40px align=center>
                                <td><font color=blue><b>三</b></font>
                                <td><input type="checkbox" id="41" name="41"/></td>
                                <td><input type="checkbox" id="42" name="42"/></td>
                                <td><input type="checkbox" id="43" name="43"/></td>
                                <td><input type="checkbox" id="44" name="44"/></td>
                                <td><input type="checkbox" id="45" name="45"/></td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <input type="hidden" id="id" name="id" value="{{ course.id}}"/>
                        <button type="submit" class="btn btn-primary">保存</button>&nbsp;&nbsp;
                        <button type="button" class="btn btn-primary" onclick="resetValue()">重置</button>&nbsp;&nbsp;
                        <font color="red" id="error"></font>
                    </div>
                </div>
            </form>
        </div>
    </div>
{% endblock %}

